<?php


namespace api\modules\v1\controllers;
use api\controllers\OnAuthController;
use common\models\byxcx\Cate;
use common\models\byxcx\Article;
use Yii;
class ArticleController extends OnAuthController
{
    public $modelClass = '';
    protected $authOptional = ['headlines','dynamic','article'];
    //柏萤头条
    public function actionHeadlines(){
        $data =Article::find()
            ->select('id,title')
            ->where(['cate_id'=>47])
            ->asarray()
            ->all();
        if ($data) {
            return $data;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
    //咨询动态
    public function actionDynamic(){
        $data =Article::find()
            ->select('title')
            ->where(['cate_id'=>48])
            ->asarray()
            ->all();
        if ($data) {
            return $data;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
    //文章
    public function actionArticle(){
        $id =Yii::$app->request->get();
        $data =Article::find()
            ->select('title,content')
            ->where(['id'=>$id])
            ->asarray()
            ->all();
        if ($data) {
            return $data;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }

}